{% extends "admin/pub/base.html" %}



{% block title %}
<title>订单管理</title>
{% endblock %}

{% block con-header %}
{% endblock %}

{% block content-body %}
<div class="widget am-cf">
  <div class="widget-head am-cf">
    <div class="widget-title  am-cf"> 订单列表</div></div>
  <div class="widget-body  am-fr">
    <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
      <div class="am-form-group">
        <div class="am-btn-toolbar">
          <div class="am-btn-group am-btn-group-xs">
            <button type="button" class="am-btn am-btn-default am-btn-success">
              <span class="am-icon-plus"></span>新增</button>
            <button type="button" class="am-btn am-btn-default am-btn-secondary">
              <span class="am-icon-save"></span>保存</button>
            <button type="button" class="am-btn am-btn-default am-btn-warning">
              <span class="am-icon-archive"></span>审核</button>
            <button type="button" class="am-btn am-btn-default am-btn-danger">
              <span class="am-icon-trash-o"></span>删除</button>
          </div>
        </div>
      </div>
    </div>

    <form>
      <!--<div class="am-u-sm-12 am-u-md-6 am-u-lg-3">-->
        <!--<div class="am-form-group tpl-table-list-select">-->
          <!--<select name="types" data-am-selected="{btnSize: 'sm'}" style="display: none;">-->
            <!--<option {% if request.GET.types == 'all' %} selected {% endif %} value="all" >全部条件</option>-->
            <!--<option {% if request.GET.types == 'username' %} selected {% endif %} value="username" >用户名</option>-->
            <!--<option {% if request.GET.types == 'email' %} selected {% endif %} value="email" >邮箱</option>-->
            <!--<option {% if request.GET.types == 'phone' %} selected {% endif %} value="phone" >手机号</option>-->
            <!--<option {% if request.GET.types == 'age' %} selected {% endif %} value="age" >年龄</option>-->
            <!--<option {% if request.GET.types == 'sex' %} selected {% endif %} value="sex" >性别</option>-->
            <!--<option {% if request.GET.types == 'status' %} selected {% endif %} value="status" >状态</option>-->
          <!--</select>-->

        <!--</div>-->
      <!--</div>-->
        <!--搜索框 关闭-->

      <!--<div class="am-u-sm-12 am-u-md-12 am-u-lg-3">-->
        <!--<div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">-->
          <!--<input type="text" class="am-form-field " name="keywords" value="{{ request.GET.keywords }}">-->
          <!--<span class="am-input-group-btn">-->
            <!--<button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search"></button>-->
          <!--</span>-->
        <!--</div>-->
      <!--</div>-->

    </form>

    <div class="am-u-sm-12">
      <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
        <thead>
          <tr>

            <th>订单id</th>
            <th>用户</th>
            <th>收货地址</th>
            <th>总价</th>
            <th>商品总数</th>
            <th>创建时间</th>
            <th>状态</th>
            <th>查看订单</th>

            </tr>
        </thead>
        <tbody>
        {% for i in orderall %}
          <tr class="gradeX">
            <td class="am-text-middle">{{ i.id }}</td>
            <td class="am-text-middle">{{ i.uid.username }}</td>
            <td class="am-text-middle">{{ i.add }}</td>
            <td class="am-text-middle">{{ i.totalprice }}</td>
            <td class="am-text-middle">{{ i.totalnum }}</td>
            <td class="am-text-middle">{{ i.addtime|date:'Y-m-d H:i:s' }}</td>

            <td class="am-text-middle">
              <select aid="{{ i.id }}" class="order_status" style="color:#000">
                <option value="1" {% if i.status == 1 %} selected {% endif %}>待付款</option>
                <option value="2" {% if i.status == 2 %} selected {% endif %}>待发货</option>
                <option value="3" {% if i.status == 3 %} selected {% endif %}>已发货</option>
                <option value="4" {% if i.status == 4 %} selected {% endif %}>取消订单</option>
              </select>
            </td>
            <td>
              <!--莫太框-->
              <div class="open_new" style="color:white;">
                <a href="{% url 'orderdel' i.id %}">取消订单</a>
             </div>
            </td>

          </tr>
        {% endfor %}


          <!-- more data --></tbody>
      </table>
    </div>
    <div class="am-u-lg-12 am-cf">
      <div class="am-fr">
        <ul class="am-pagination tpl-pagination">

            <!--分页加载在这里-->

        </ul>
      </div>
    </div>
  </div>
</div>




<script>
  // 发送ajax修改订单状态
  $('.order_status').change(function(){
    var val = $(this).val()     // 选择的哪一个值
    var id = $(this).attr('aid')    // 订单id
    // 发送请求给后orderstatus,不需要获取数据.
    $.get('{% url 'orderstatus' %}',{Oid:id,status:val})

  })


</script>
{% endblock %}




